<?php

class Common_Controller_Admin extends Common_Controller_Main {

    public function init() {
        parent::init();

        $this->adapter = new Common_Auth_Adapter_DbTable(
                        Zend_Db_Table::getDefaultAdapter(),
                        'users',
                        'login',
                        'password',
                        "MD5(CONCAT('"
                        . Zend_Registry::get('staticSalt')
                        . '\', ?)) and `active`=1 and `confirmed`=1 and `deleted`=0 and `rola`=' . Application_Model_Users::ROLA_ADMIN . ''
        );


        $this->_helper->layout()->setLayout('admin');
        $this->addCssFile('redmond/jquery-ui-1.9.2.custom.min.css');
        $this->addCssFile('main.css');
        $this->addCssFile('ui.css'); 
        $this->addJsFile('tiny_mce/jquery.tinymce.js');
        $this->addJsFile('jquery-ui-1.9.2.custom.min.js');
    }

    public function indexAction() {
        if ($this->userObject->rola != Application_Model_Users::ROLA_ADMIN) {
            $this->auth->clearIdentity();
            $this->redirect('/');
        }
    }

}